// toGooglePlayer
import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:smartloan_mdc/route/app_routes.dart';
import 'package:smartloan_mdc/utils/locator/app_config.dart';
import 'package:smartloan_mdc/utils/locator/locator.dart';
import 'package:smartloan_mdc/utils/storage/get_storage.dart';

import '../javascript_channel.dart';

class SetCountryMsg extends JavaScriptChannel {
  @override
  List<String> get actions => ['setCountryMsg'];

  @override
  onReceive(Map newMsg) {
    locator<AppConfig>().setModel(newMsg['data']);
    AppStorage().writeKey(StorageKey.countryConfig, newMsg['data']);
    Get.offAndToNamed(AppRoutes.splash);
  }
}

class ClearCountryMsg extends JavaScriptChannel {
  @override
  List<String> get actions => ['clearCountryMsg'];

  @override
  onReceive(Map newMsg) {
    AppStorage().removeKey(StorageKey.countryConfig);
  }
}